<?php
    $content="";
    
    $op1=render($p[1],'op1_off.html');
    $op2=render($p[2],'op2_off.html');
    $op3=render($p[3],'op3_off.html');
    $op4=render($p[4],'op4_off.html');
    
    
    //-- Contact page-------------------------------- OP1
    if ($ssVar=="[act:1]"){
        $data="";
        foreach ($contact as $key=> $value){
            $data.=$value;
        }
        
        $content=$data;
        $op1=render($p[1],'op1_on.html');
    }
    
    //-- Incaltaminte -------------------------------- OP2
    if ($ssVar=="[act:2]"){
        $content=renderData($data["model"],$mph);
        $op2=render($p[2],'op2_on.html');
    }
    
    //-- Imbracaminte -------------------------------- OP3
    if ($ssVar=="[act:3]"){
        $thumbs="";
        
        foreach ($h as $model=> $value){
            $array=$h[$model];
            $array["HREF"]=$mph."big_".$array["URL"];
            $array["URL"]=$mph.$array["URL"];
            $array["REL"]="lightbox";
    
            $thumbs=$thumbs.render($array,'item.html');
        }
        
        $content=renderData($data,$mph);
        $op3=render($p[3],'op3_on.html');
    }
    
    //-- Diverse page--------------------------------- OP4
    if ($ssVar=="[act:4]"){
        
        $op4=render($p[4],'op4_on.html');
    }
    
    $src=render(array(
        'CONTENT'=>$content,
        'TITLE'=>$data["title"],
        'YM'=>$data["messenger_id"],
        'OP1'=>$op1,
        'OP2'=>$op2,
        'OP3'=>$op3,
        'OP4'=>$op4,
    ),"template.html");

      
    
    
    
    
    
    
    
    function renderData($data,$mph){
	    $thumbs="";
	    
        foreach ($data as $model=> $value){
            $array=$data[$model];
            $array["HREF"]=$mph."big_".$array["URL"];
            $array["URL"]=$mph.$array["URL"];
            $array["ID"]="ic".$model;
            
            if (file_exists($array["HREF"])){
            	$array["REL"]="lightbox";
            	$thumbs=$thumbs.render($array,'item.html');
        	}else{
	        	$array["REL"]="#";
	        	$array["HREF"]="#";
	        	$thumbs=$thumbs.render($array,'item_off.html');
        	}
        }
        
        return $thumbs;
    }
    
    echo $src;
?>